// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Generated by the Codegen C++ plugin.
// If you make any local changes, they will be lost.
// source: google/cloud/pubsublite/v1/admin.proto

#include "google/cloud/pubsublite/admin_connection.h"
#include "google/cloud/pubsublite/admin_options.h"
#include "google/cloud/pubsublite/internal/admin_option_defaults.h"
#include "google/cloud/pubsublite/internal/admin_stub_factory.h"
#include "google/cloud/background_threads.h"
#include "google/cloud/common_options.h"
#include "google/cloud/grpc_options.h"
#include "google/cloud/internal/async_long_running_operation.h"
#include "google/cloud/internal/pagination_range.h"
#include "google/cloud/internal/retry_loop.h"
#include <memory>

namespace google {
namespace cloud {
namespace pubsublite {
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN

AdminServiceConnection::~AdminServiceConnection() = default;

StatusOr<google::cloud::pubsublite::v1::Topic>
AdminServiceConnection::CreateTopic(
    google::cloud::pubsublite::v1::CreateTopicRequest const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

StatusOr<google::cloud::pubsublite::v1::Topic> AdminServiceConnection::GetTopic(
    google::cloud::pubsublite::v1::GetTopicRequest const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

StatusOr<google::cloud::pubsublite::v1::TopicPartitions>
AdminServiceConnection::GetTopicPartitions(
    google::cloud::pubsublite::v1::GetTopicPartitionsRequest const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

StreamRange<google::cloud::pubsublite::v1::Topic>
AdminServiceConnection::ListTopics(
    google::cloud::pubsublite::v1::ListTopicsRequest request) {
  return google::cloud::internal::MakePaginationRange<
      StreamRange<google::cloud::pubsublite::v1::Topic>>(
      std::move(request),
      [](google::cloud::pubsublite::v1::ListTopicsRequest const&) {
        return StatusOr<google::cloud::pubsublite::v1::ListTopicsResponse>{};
      },
      [](google::cloud::pubsublite::v1::ListTopicsResponse const&) {
        return std::vector<google::cloud::pubsublite::v1::Topic>();
      });
}

StatusOr<google::cloud::pubsublite::v1::Topic>
AdminServiceConnection::UpdateTopic(
    google::cloud::pubsublite::v1::UpdateTopicRequest const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

Status AdminServiceConnection::DeleteTopic(
    google::cloud::pubsublite::v1::DeleteTopicRequest const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

StreamRange<std::string> AdminServiceConnection::ListTopicSubscriptions(
    google::cloud::pubsublite::v1::ListTopicSubscriptionsRequest request) {
  return google::cloud::internal::MakePaginationRange<StreamRange<std::string>>(
      std::move(request),
      [](google::cloud::pubsublite::v1::ListTopicSubscriptionsRequest const&) {
        return StatusOr<
            google::cloud::pubsublite::v1::ListTopicSubscriptionsResponse>{};
      },
      [](google::cloud::pubsublite::v1::ListTopicSubscriptionsResponse const&) {
        return std::vector<std::string>();
      });
}

StatusOr<google::cloud::pubsublite::v1::Subscription>
AdminServiceConnection::CreateSubscription(
    google::cloud::pubsublite::v1::CreateSubscriptionRequest const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

StatusOr<google::cloud::pubsublite::v1::Subscription>
AdminServiceConnection::GetSubscription(
    google::cloud::pubsublite::v1::GetSubscriptionRequest const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

StreamRange<google::cloud::pubsublite::v1::Subscription>
AdminServiceConnection::ListSubscriptions(
    google::cloud::pubsublite::v1::ListSubscriptionsRequest request) {
  return google::cloud::internal::MakePaginationRange<
      StreamRange<google::cloud::pubsublite::v1::Subscription>>(
      std::move(request),
      [](google::cloud::pubsublite::v1::ListSubscriptionsRequest const&) {
        return StatusOr<
            google::cloud::pubsublite::v1::ListSubscriptionsResponse>{};
      },
      [](google::cloud::pubsublite::v1::ListSubscriptionsResponse const&) {
        return std::vector<google::cloud::pubsublite::v1::Subscription>();
      });
}

StatusOr<google::cloud::pubsublite::v1::Subscription>
AdminServiceConnection::UpdateSubscription(
    google::cloud::pubsublite::v1::UpdateSubscriptionRequest const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

Status AdminServiceConnection::DeleteSubscription(
    google::cloud::pubsublite::v1::DeleteSubscriptionRequest const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

future<StatusOr<google::cloud::pubsublite::v1::SeekSubscriptionResponse>>
AdminServiceConnection::SeekSubscription(
    google::cloud::pubsublite::v1::SeekSubscriptionRequest const&) {
  return google::cloud::make_ready_future<
      StatusOr<google::cloud::pubsublite::v1::SeekSubscriptionResponse>>(
      Status(StatusCode::kUnimplemented, "not implemented"));
}

StatusOr<google::cloud::pubsublite::v1::Reservation>
AdminServiceConnection::CreateReservation(
    google::cloud::pubsublite::v1::CreateReservationRequest const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

StatusOr<google::cloud::pubsublite::v1::Reservation>
AdminServiceConnection::GetReservation(
    google::cloud::pubsublite::v1::GetReservationRequest const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

StreamRange<google::cloud::pubsublite::v1::Reservation>
AdminServiceConnection::ListReservations(
    google::cloud::pubsublite::v1::ListReservationsRequest request) {
  return google::cloud::internal::MakePaginationRange<
      StreamRange<google::cloud::pubsublite::v1::Reservation>>(
      std::move(request),
      [](google::cloud::pubsublite::v1::ListReservationsRequest const&) {
        return StatusOr<
            google::cloud::pubsublite::v1::ListReservationsResponse>{};
      },
      [](google::cloud::pubsublite::v1::ListReservationsResponse const&) {
        return std::vector<google::cloud::pubsublite::v1::Reservation>();
      });
}

StatusOr<google::cloud::pubsublite::v1::Reservation>
AdminServiceConnection::UpdateReservation(
    google::cloud::pubsublite::v1::UpdateReservationRequest const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

Status AdminServiceConnection::DeleteReservation(
    google::cloud::pubsublite::v1::DeleteReservationRequest const&) {
  return Status(StatusCode::kUnimplemented, "not implemented");
}

StreamRange<std::string> AdminServiceConnection::ListReservationTopics(
    google::cloud::pubsublite::v1::ListReservationTopicsRequest request) {
  return google::cloud::internal::MakePaginationRange<StreamRange<std::string>>(
      std::move(request),
      [](google::cloud::pubsublite::v1::ListReservationTopicsRequest const&) {
        return StatusOr<
            google::cloud::pubsublite::v1::ListReservationTopicsResponse>{};
      },
      [](google::cloud::pubsublite::v1::ListReservationTopicsResponse const&) {
        return std::vector<std::string>();
      });
}

namespace {
class AdminServiceConnectionImpl : public AdminServiceConnection {
 public:
  AdminServiceConnectionImpl(
      std::unique_ptr<google::cloud::BackgroundThreads> background,
      std::shared_ptr<pubsublite_internal::AdminServiceStub> stub,
      Options const& options)
      : background_(std::move(background)),
        stub_(std::move(stub)),
        retry_policy_prototype_(
            options.get<AdminServiceRetryPolicyOption>()->clone()),
        backoff_policy_prototype_(
            options.get<AdminServiceBackoffPolicyOption>()->clone()),
        polling_policy_prototype_(
            options.get<AdminServicePollingPolicyOption>()->clone()),
        idempotency_policy_(
            options.get<AdminServiceConnectionIdempotencyPolicyOption>()
                ->clone()) {}

  ~AdminServiceConnectionImpl() override = default;

  StatusOr<google::cloud::pubsublite::v1::Topic> CreateTopic(
      google::cloud::pubsublite::v1::CreateTopicRequest const& request)
      override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->CreateTopic(request),
        [this](
            grpc::ClientContext& context,
            google::cloud::pubsublite::v1::CreateTopicRequest const& request) {
          return stub_->CreateTopic(context, request);
        },
        request, __func__);
  }

  StatusOr<google::cloud::pubsublite::v1::Topic> GetTopic(
      google::cloud::pubsublite::v1::GetTopicRequest const& request) override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->GetTopic(request),
        [this](grpc::ClientContext& context,
               google::cloud::pubsublite::v1::GetTopicRequest const& request) {
          return stub_->GetTopic(context, request);
        },
        request, __func__);
  }

  StatusOr<google::cloud::pubsublite::v1::TopicPartitions> GetTopicPartitions(
      google::cloud::pubsublite::v1::GetTopicPartitionsRequest const& request)
      override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->GetTopicPartitions(request),
        [this](grpc::ClientContext& context,
               google::cloud::pubsublite::v1::GetTopicPartitionsRequest const&
                   request) {
          return stub_->GetTopicPartitions(context, request);
        },
        request, __func__);
  }

  StreamRange<google::cloud::pubsublite::v1::Topic> ListTopics(
      google::cloud::pubsublite::v1::ListTopicsRequest request) override {
    request.clear_page_token();
    auto stub = stub_;
    auto retry = std::shared_ptr<AdminServiceRetryPolicy const>(
        retry_policy_prototype_->clone());
    auto backoff = std::shared_ptr<BackoffPolicy const>(
        backoff_policy_prototype_->clone());
    auto idempotency = idempotency_policy_->ListTopics(request);
    char const* function_name = __func__;
    return google::cloud::internal::MakePaginationRange<
        StreamRange<google::cloud::pubsublite::v1::Topic>>(
        std::move(request),
        [stub, retry, backoff, idempotency, function_name](
            google::cloud::pubsublite::v1::ListTopicsRequest const& r) {
          return google::cloud::internal::RetryLoop(
              retry->clone(), backoff->clone(), idempotency,
              [stub](grpc::ClientContext& context,
                     google::cloud::pubsublite::v1::ListTopicsRequest const&
                         request) {
                return stub->ListTopics(context, request);
              },
              r, function_name);
        },
        [](google::cloud::pubsublite::v1::ListTopicsResponse r) {
          std::vector<google::cloud::pubsublite::v1::Topic> result(
              r.topics().size());
          auto& messages = *r.mutable_topics();
          std::move(messages.begin(), messages.end(), result.begin());
          return result;
        });
  }

  StatusOr<google::cloud::pubsublite::v1::Topic> UpdateTopic(
      google::cloud::pubsublite::v1::UpdateTopicRequest const& request)
      override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->UpdateTopic(request),
        [this](
            grpc::ClientContext& context,
            google::cloud::pubsublite::v1::UpdateTopicRequest const& request) {
          return stub_->UpdateTopic(context, request);
        },
        request, __func__);
  }

  Status DeleteTopic(google::cloud::pubsublite::v1::DeleteTopicRequest const&
                         request) override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->DeleteTopic(request),
        [this](
            grpc::ClientContext& context,
            google::cloud::pubsublite::v1::DeleteTopicRequest const& request) {
          return stub_->DeleteTopic(context, request);
        },
        request, __func__);
  }

  StreamRange<std::string> ListTopicSubscriptions(
      google::cloud::pubsublite::v1::ListTopicSubscriptionsRequest request)
      override {
    request.clear_page_token();
    auto stub = stub_;
    auto retry = std::shared_ptr<AdminServiceRetryPolicy const>(
        retry_policy_prototype_->clone());
    auto backoff = std::shared_ptr<BackoffPolicy const>(
        backoff_policy_prototype_->clone());
    auto idempotency = idempotency_policy_->ListTopicSubscriptions(request);
    char const* function_name = __func__;
    return google::cloud::internal::MakePaginationRange<
        StreamRange<std::string>>(
        std::move(request),
        [stub, retry, backoff, idempotency, function_name](
            google::cloud::pubsublite::v1::ListTopicSubscriptionsRequest const&
                r) {
          return google::cloud::internal::RetryLoop(
              retry->clone(), backoff->clone(), idempotency,
              [stub](grpc::ClientContext& context,
                     google::cloud::pubsublite::v1::
                         ListTopicSubscriptionsRequest const& request) {
                return stub->ListTopicSubscriptions(context, request);
              },
              r, function_name);
        },
        [](google::cloud::pubsublite::v1::ListTopicSubscriptionsResponse r) {
          std::vector<std::string> result(r.subscriptions().size());
          auto& messages = *r.mutable_subscriptions();
          std::move(messages.begin(), messages.end(), result.begin());
          return result;
        });
  }

  StatusOr<google::cloud::pubsublite::v1::Subscription> CreateSubscription(
      google::cloud::pubsublite::v1::CreateSubscriptionRequest const& request)
      override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->CreateSubscription(request),
        [this](grpc::ClientContext& context,
               google::cloud::pubsublite::v1::CreateSubscriptionRequest const&
                   request) {
          return stub_->CreateSubscription(context, request);
        },
        request, __func__);
  }

  StatusOr<google::cloud::pubsublite::v1::Subscription> GetSubscription(
      google::cloud::pubsublite::v1::GetSubscriptionRequest const& request)
      override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->GetSubscription(request),
        [this](grpc::ClientContext& context,
               google::cloud::pubsublite::v1::GetSubscriptionRequest const&
                   request) {
          return stub_->GetSubscription(context, request);
        },
        request, __func__);
  }

  StreamRange<google::cloud::pubsublite::v1::Subscription> ListSubscriptions(
      google::cloud::pubsublite::v1::ListSubscriptionsRequest request)
      override {
    request.clear_page_token();
    auto stub = stub_;
    auto retry = std::shared_ptr<AdminServiceRetryPolicy const>(
        retry_policy_prototype_->clone());
    auto backoff = std::shared_ptr<BackoffPolicy const>(
        backoff_policy_prototype_->clone());
    auto idempotency = idempotency_policy_->ListSubscriptions(request);
    char const* function_name = __func__;
    return google::cloud::internal::MakePaginationRange<
        StreamRange<google::cloud::pubsublite::v1::Subscription>>(
        std::move(request),
        [stub, retry, backoff, idempotency, function_name](
            google::cloud::pubsublite::v1::ListSubscriptionsRequest const& r) {
          return google::cloud::internal::RetryLoop(
              retry->clone(), backoff->clone(), idempotency,
              [stub](
                  grpc::ClientContext& context,
                  google::cloud::pubsublite::v1::ListSubscriptionsRequest const&
                      request) {
                return stub->ListSubscriptions(context, request);
              },
              r, function_name);
        },
        [](google::cloud::pubsublite::v1::ListSubscriptionsResponse r) {
          std::vector<google::cloud::pubsublite::v1::Subscription> result(
              r.subscriptions().size());
          auto& messages = *r.mutable_subscriptions();
          std::move(messages.begin(), messages.end(), result.begin());
          return result;
        });
  }

  StatusOr<google::cloud::pubsublite::v1::Subscription> UpdateSubscription(
      google::cloud::pubsublite::v1::UpdateSubscriptionRequest const& request)
      override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->UpdateSubscription(request),
        [this](grpc::ClientContext& context,
               google::cloud::pubsublite::v1::UpdateSubscriptionRequest const&
                   request) {
          return stub_->UpdateSubscription(context, request);
        },
        request, __func__);
  }

  Status DeleteSubscription(
      google::cloud::pubsublite::v1::DeleteSubscriptionRequest const& request)
      override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->DeleteSubscription(request),
        [this](grpc::ClientContext& context,
               google::cloud::pubsublite::v1::DeleteSubscriptionRequest const&
                   request) {
          return stub_->DeleteSubscription(context, request);
        },
        request, __func__);
  }

  future<StatusOr<google::cloud::pubsublite::v1::SeekSubscriptionResponse>>
  SeekSubscription(google::cloud::pubsublite::v1::SeekSubscriptionRequest const&
                       request) override {
    auto stub = stub_;
    return google::cloud::internal::AsyncLongRunningOperation<
        google::cloud::pubsublite::v1::SeekSubscriptionResponse>(
        background_->cq(), request,
        [stub](google::cloud::CompletionQueue& cq,
               std::unique_ptr<grpc::ClientContext> context,
               google::cloud::pubsublite::v1::SeekSubscriptionRequest const&
                   request) {
          return stub->AsyncSeekSubscription(cq, std::move(context), request);
        },
        [stub](google::cloud::CompletionQueue& cq,
               std::unique_ptr<grpc::ClientContext> context,
               google::longrunning::GetOperationRequest const& request) {
          return stub->AsyncGetOperation(cq, std::move(context), request);
        },
        [stub](google::cloud::CompletionQueue& cq,
               std::unique_ptr<grpc::ClientContext> context,
               google::longrunning::CancelOperationRequest const& request) {
          return stub->AsyncCancelOperation(cq, std::move(context), request);
        },
        &google::cloud::internal::ExtractLongRunningResultResponse<
            google::cloud::pubsublite::v1::SeekSubscriptionResponse>,
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->SeekSubscription(request),
        polling_policy_prototype_->clone(), __func__);
  }

  StatusOr<google::cloud::pubsublite::v1::Reservation> CreateReservation(
      google::cloud::pubsublite::v1::CreateReservationRequest const& request)
      override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->CreateReservation(request),
        [this](grpc::ClientContext& context,
               google::cloud::pubsublite::v1::CreateReservationRequest const&
                   request) {
          return stub_->CreateReservation(context, request);
        },
        request, __func__);
  }

  StatusOr<google::cloud::pubsublite::v1::Reservation> GetReservation(
      google::cloud::pubsublite::v1::GetReservationRequest const& request)
      override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->GetReservation(request),
        [this](grpc::ClientContext& context,
               google::cloud::pubsublite::v1::GetReservationRequest const&
                   request) { return stub_->GetReservation(context, request); },
        request, __func__);
  }

  StreamRange<google::cloud::pubsublite::v1::Reservation> ListReservations(
      google::cloud::pubsublite::v1::ListReservationsRequest request) override {
    request.clear_page_token();
    auto stub = stub_;
    auto retry = std::shared_ptr<AdminServiceRetryPolicy const>(
        retry_policy_prototype_->clone());
    auto backoff = std::shared_ptr<BackoffPolicy const>(
        backoff_policy_prototype_->clone());
    auto idempotency = idempotency_policy_->ListReservations(request);
    char const* function_name = __func__;
    return google::cloud::internal::MakePaginationRange<
        StreamRange<google::cloud::pubsublite::v1::Reservation>>(
        std::move(request),
        [stub, retry, backoff, idempotency, function_name](
            google::cloud::pubsublite::v1::ListReservationsRequest const& r) {
          return google::cloud::internal::RetryLoop(
              retry->clone(), backoff->clone(), idempotency,
              [stub](
                  grpc::ClientContext& context,
                  google::cloud::pubsublite::v1::ListReservationsRequest const&
                      request) {
                return stub->ListReservations(context, request);
              },
              r, function_name);
        },
        [](google::cloud::pubsublite::v1::ListReservationsResponse r) {
          std::vector<google::cloud::pubsublite::v1::Reservation> result(
              r.reservations().size());
          auto& messages = *r.mutable_reservations();
          std::move(messages.begin(), messages.end(), result.begin());
          return result;
        });
  }

  StatusOr<google::cloud::pubsublite::v1::Reservation> UpdateReservation(
      google::cloud::pubsublite::v1::UpdateReservationRequest const& request)
      override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->UpdateReservation(request),
        [this](grpc::ClientContext& context,
               google::cloud::pubsublite::v1::UpdateReservationRequest const&
                   request) {
          return stub_->UpdateReservation(context, request);
        },
        request, __func__);
  }

  Status DeleteReservation(
      google::cloud::pubsublite::v1::DeleteReservationRequest const& request)
      override {
    return google::cloud::internal::RetryLoop(
        retry_policy_prototype_->clone(), backoff_policy_prototype_->clone(),
        idempotency_policy_->DeleteReservation(request),
        [this](grpc::ClientContext& context,
               google::cloud::pubsublite::v1::DeleteReservationRequest const&
                   request) {
          return stub_->DeleteReservation(context, request);
        },
        request, __func__);
  }

  StreamRange<std::string> ListReservationTopics(
      google::cloud::pubsublite::v1::ListReservationTopicsRequest request)
      override {
    request.clear_page_token();
    auto stub = stub_;
    auto retry = std::shared_ptr<AdminServiceRetryPolicy const>(
        retry_policy_prototype_->clone());
    auto backoff = std::shared_ptr<BackoffPolicy const>(
        backoff_policy_prototype_->clone());
    auto idempotency = idempotency_policy_->ListReservationTopics(request);
    char const* function_name = __func__;
    return google::cloud::internal::MakePaginationRange<
        StreamRange<std::string>>(
        std::move(request),
        [stub, retry, backoff, idempotency, function_name](
            google::cloud::pubsublite::v1::ListReservationTopicsRequest const&
                r) {
          return google::cloud::internal::RetryLoop(
              retry->clone(), backoff->clone(), idempotency,
              [stub](grpc::ClientContext& context,
                     google::cloud::pubsublite::v1::
                         ListReservationTopicsRequest const& request) {
                return stub->ListReservationTopics(context, request);
              },
              r, function_name);
        },
        [](google::cloud::pubsublite::v1::ListReservationTopicsResponse r) {
          std::vector<std::string> result(r.topics().size());
          auto& messages = *r.mutable_topics();
          std::move(messages.begin(), messages.end(), result.begin());
          return result;
        });
  }

 private:
  std::unique_ptr<google::cloud::BackgroundThreads> background_;
  std::shared_ptr<pubsublite_internal::AdminServiceStub> stub_;
  std::unique_ptr<AdminServiceRetryPolicy const> retry_policy_prototype_;
  std::unique_ptr<BackoffPolicy const> backoff_policy_prototype_;
  std::unique_ptr<PollingPolicy const> polling_policy_prototype_;
  std::unique_ptr<AdminServiceConnectionIdempotencyPolicy> idempotency_policy_;
};
}  // namespace

std::shared_ptr<AdminServiceConnection> MakeAdminServiceConnection(
    Options options) {
  internal::CheckExpectedOptions<CommonOptionList, GrpcOptionList,
                                 AdminServicePolicyOptionList>(options,
                                                               __func__);
  options = pubsublite_internal::AdminServiceDefaultOptions(std::move(options));
  auto background = internal::MakeBackgroundThreadsFactory(options)();
  auto stub = pubsublite_internal::CreateDefaultAdminServiceStub(
      background->cq(), options);
  return std::make_shared<AdminServiceConnectionImpl>(std::move(background),
                                                      std::move(stub), options);
}

GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
}  // namespace pubsublite
}  // namespace cloud
}  // namespace google

namespace google {
namespace cloud {
namespace pubsublite_internal {
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN

std::shared_ptr<pubsublite::AdminServiceConnection> MakeAdminServiceConnection(
    std::shared_ptr<AdminServiceStub> stub, Options options) {
  options = AdminServiceDefaultOptions(std::move(options));
  return std::make_shared<pubsublite::AdminServiceConnectionImpl>(
      internal::MakeBackgroundThreadsFactory(options)(), std::move(stub),
      std::move(options));
}

GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
}  // namespace pubsublite_internal
}  // namespace cloud
}  // namespace google
